/*
 * 格式化时间 xxxx-xx-xx
 * @params {string/number}  timestamp   时间戳
 */
 //转换时间戳
let formatTime1 = function(timestamp) {
	let time = Number(timestamp);
	if(time != NaN) {
		time = new Date(time);
	    let year = time.getFullYear(),
	        mon = time.getMonth() + 1,
	        date = time.getDate();

	     mon = mon > 9 ? mon : '0' + mon;
	     date = date > 9 ? date: '0' + date;

	    return `${year}-${mon}-${date}`;
	}else {
	    return 0;
	}
} 
//转换是否一次性用水
let formDisposable = function(disposable) {
	if(disposable == true) {
		return `是`;
	}
	else if(disposable == false) {
		return `否`;
	}
	else {
		return ``;
	}
}
//转换是否飞滴号是否已修改
let formFeidiAccountStatus = function(feidiAccountStatus) {
	if(feidiAccountStatus == true) {
		return `是`;
	}
	else if(feidiAccountStatus == false) {
		return `否`;
	}
	else {
		return ``;
	}
}
//转换提交表单
let formData = function(obj) {
	let data = new FormData();
    for(let k in obj) {
        data.append(k, obj[k])
    }

    return data;
}

module.exports = {
	formatTime1: formatTime1,
	formDisposable: formDisposable,
	formFeidiAccountStatus: formFeidiAccountStatus,
	formData: formData
}